package com.veeder.datacollection.rs232.response.handler;

import com.veeder.datacollection.exception.SyntaxException;
import com.veeder.datacollection.rs232.response.TankResponseReport;
import com.veeder.datacollection.util.DateUtil;

public class RS602RspHandler extends CmdRspParser {

	@Override
	public TankResponseReport<String> parseCoreResponse(String coreResponse) throws SyntaxException {
		TankResponseReport<String> result = null;
		try {
			
			result =new TankResponseReport<String>();
			int position = 6;
			result.setTlsSysDate(
					DateUtil.convertToDate(coreResponse.substring(position, position += 10), DateUtil.DateFormat1));
			while (position < coreResponse.length()) {
				
				int tankId = Integer.parseInt(coreResponse.substring(position, position += 2));
				String label = coreResponse.substring(position, position += 20);
				result.setTankReponse(tankId, label);
			}
		} catch (Exception e) {
			throw new SyntaxException(e.toString());
		}

		return result;
	}

}
